<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>

    var persons = [
        {
            username: '张飞',
            sex: '男',
            salary: 50000
        },
        {
            username: '关羽',
            sex: '男',
            salary: 60000
        },
        {
            username: '刘备',
            sex: '男',
            salary: 30000
        }
    ]

    // let newPersons=persons.map(function(value){

    //     // return value.salary +2000   // 新数组的值
    //     return {
    //         // username:value.username,
    //         // sex:value.sex,

    //         ...value,
    //         salary:value.salary +2000
    //     }   // 新数组的值
    // })


    let newPersons = persons.map(value=> ({...value,salary: value.salary + 2000}))
    console.log(newPersons);
    console.log(persons);




// let newPersons=persons.map(function(value){

//     value.salary+=2000

//     return  value
// })
// console.log(newPersons);
// console.log(persons);











</script>